package main

import "fmt"

func main() {
	naturals := make(chan int)
	squares := make(chan int)

	//计数器Counter
	go func() {
		for x := 0; ; x++ {
			naturals <- x
		}
	}()

	//Squarer
	go func() {
		for {
			x := <-naturals
			squares <- x * x
		}
	}()

	//Printer
	for {
		fmt.Println(<-squares)
	}

	//三个逻辑， 必须先输入到naturals， 在将平方输入到管道， 再将管道中的数据输入到显示器
}

func mirroredQuery() string {
	responses := make(chan string, 3)
	go func() { responses <- request("asia.gopl.io") }()
	go func() { responses <- request("europe.gopl.io") }()
	go func() { responses <- request("americas.gopl.io") }()
	return <-responses
}

func request(hostname string) (response string) {
	return hostname
}
